#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <exception> 
using namespace std;

int MyStrLen(const char *);

class MyString
{
    char *_pstr;
    int _len;
    int _size;

public:
    MyString();
    MyString(const char*);
    MyString(const char*, int);

    MyString(const int);
    MyString(const long int);
    MyString(const long long int);

    //MyString(const unsigned int&);
    //MyString(const unsigned long int&);
    //MyString(const unsigned long long int&);

    MyString(const float, const unsigned int decimalLen = 1u);
    MyString(const double, const unsigned int decimalLen = 1u);
    MyString(const MyString &);

    int len() const;
    int size() const;
    bool isEmpty();

    int toInt();
    float toFloat();
    MyString subString(const int, const int);
    int find(const MyString &);
    char *toCString(const int, const int);

    MyString operator+(const MyString&);
    MyString operator-(const MyString&);

    MyString& operator=(const MyString &);
    MyString& operator+=(const MyString&);
    MyString& operator-=(const MyString&);
    friend ostream &operator<<(ostream &, const MyString &);

    ~MyString();
};

class convert_error : public runtime_error {
    const char* _type;
public:
    convert_error(const char* _RawStr, const char* _Type): runtime_error(_RawStr), _type(_Type) {}
    friend ostream& operator<<(ostream& os, const convert_error& ce);
    ~convert_error() {}
};
